<?php
include_once($_SERVER['DOCUMENT_ROOT']."ExiaStore/Model/BDD.php");
include($_SERVER['DOCUMENT_ROOT']."ExiaStore/Model/Users/adresse.php");
include_once($_SERVER['DOCUMENT_ROOT']."ExiaStore/Model/Security/securite.php");
         
class membre { //création d'une nouvelle classe 
    private $login;
    private $pass;
    private $email;
    private $nom;
    private $prenom;
    private $adresse;
    private $bdd;
    private $securite;
    
    public function __construct(){ //constructeur de la classe membre
        $this->securite = new securite();
        $this->bdd = new BDD();
        $this->login = $this->securite->antixss($_POST['login']);
        $this->pass = $this->securite->hachagemdp($this->securite->antixss($_POST['pass']));
        $this->email = $this->securite->antixss($_POST['email']);
        $this->nom = $this->securite->antixss($_POST['nom']);
        $this->prenom = $this->securite->antixss($_POST['prenom']);
        $this->adresse = new adresse(); //appelle un nouvel objet adresse
    }
    
        
    public function adduser(){ //Ajoute les informations de l'utilisateur dans la BDD
        $this->adresse->addToBDD(); //Ajoute les informations liées à l'adresse de l'utilisateur dans la BDD
        $req = "INSERT INTO membre (login, motDePasse, idadresse, email, nom, prenom) VALUES (:login, :motDePasse, :idadresse, :email, :nom, :prenom)";
        $rslt = $this->bdd->getBDD()->prepare($req);
        $rslt->execute(array(":login" => $this->login, ":motDePasse" => $this->pass, 
        ":idadresse" => $this->adresse->getIDAdresse(), ":email" => $this->email, ":nom" => $this->email , ":prenom"=> $this->prenom));     
    }
    
    public function getLogin(){//getter de login
        return $this->login;
    }
}

?>
